<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件</title>
</head>

<body>
    <img id="img" src="img/lyf.png" />
    <br>
    <button id="up">上一张</button>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button id="down">下一张</button>
    <script>
        function up() {
            let img = document.getElementById('img');
            img.setAttribute("src", "img/lyf.png")
        }
        function down() {
            let img = document.getElementById('img');
            img.setAttribute("src", "img/02.png")
        }
        let upBtn = document.getElementById('up');
        upBtn.onclick = up;
        let downBtn = document.getElementById('down');
        downBtn.onclick = down;
    </script>
</body>

</html>